<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/4
 * Time: 15:02
 */
header('content-type:image/png');

require ('function.php');

$im = imagecreatetruecolor(100,30);
$white = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$white);

$str = "0123456789abcdefghijklmnopqrstuvwxyz";
$len = 4;
$type = 3;
$code = code($str,$len,$type);
setcookie('coke',$code);
    for ($i= 0;$i<200;$i++) {
        $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand(2, 98), rand(2, 28), $color);
    }

for($i=0;$i<4;$i++){
    $color = imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    imagettftext($im,rand(15,20),rand(10,25),$i*20+10,rand(20,25),$color,'C:\\Windows\\Fonts\\simhei.ttf',$code[$i]);
}

imagepng($im);
imagedestroy($im);

